package cn.hackcloud.annotation.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

import cn.hackcloud.annotation.bean.Person;
import cn.hackcloud.annotation.service.BookService;

/**
 * 配置类
 * 
 * @author Created by laijun on 2018/10/19
 */
@Configuration // 告诉spring这是一个配置类
@ComponentScan(value = "cn.hackcloud", includeFilters = {
		//@Filter(type = FilterType.ANNOTATION, classes = { Controller.class }),
		//@Filter(type = FilterType.ASSIGNABLE_TYPE, classes = { BookService.class }),
		@Filter(type = FilterType.CUSTOM, classes = { MyTypeFilter.class }) }, useDefaultFilters = false)
// FilterType.ANNOTATION 按照注解
// FilterType.ASSIGNABLE_TYPE 按照指定的类型
// FilterType.ASPECTJ 使用ASPECTJ表达式
// FilterType.CUSTOM 使用自定义规则
public class MainConfig {
	// 给容器注册一个bean,id默认用方法名做id
	@Bean(value = "person")
	public Person person() {
		return new Person("laijun", 25);
	}
}
